// const baseURL = 'https://admin.2am-project.cn/api/'   //正式域名
const baseURL = 'https://twoam.phpbai.com/api/'   //测试域名

const fetch = function (url, method, data, ...args) {
	return new Promise(function (resolve, rejcet) {
		wx.request({
			url: baseURL + url,
			header: {
				'XX-Wxapp-AppId': 'wx74185b138b688f09'
			},
			method,
			data,
			...args,
			success: function (res) {
				resolve(res.data)
			},
			fail: function (error) {
				rejcet(error)
			}
		})
	})
}

export function get(url, data) {
	return fetch(url, 'GET', data)
}
export function post(url, data) {
	return fetch(url, 'POST', data)
}

export function wxLogin() {
	return new Promise(function (resolve) {
		wx.login({
			success: function (res) {
				resolve(res);
			}
		})
	})
}
